package renShiString;

import java.util.Locale;

class Student{
    public String name;
    public int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}


public class zuoYe {
    public  boolean isPalindrome(String s){
        s=s.toLowerCase();
        int left=0;
        int right=s.length()-1;
        while (left<right){
            while(left<right&&!isNumberAndCharacter(s.charAt(left))){
                left++;
            }
            while(left<right&&!isNumberAndCharacter(s.charAt(right))){
                right--;
            }
            if(s.charAt(left)==s.charAt(right)){
                left++;
                right++;
            }else{
                return false;
            }
        }
        return true;
    }
    private boolean isNumberAndCharacter(char ch){
        //判断是否为数字或者字母
        if(Character.isDigit(ch)||Character.isLetter(ch)){
            return true;
        }
        return  false;
    }
    public int firstUniqChar(String s){
        int[] count=new int[26];
        for (int i = 0; i < s.length(); i++) {
            char ch=s.charAt(i);
            count[ch-'a']++;
        }
        for (int i = 0; i < s.length(); i++) {
            char ch=s.charAt(i);
            if(count[ch-'a']==1){
                return i;
            }
        }
        return -1;
    }

}
